﻿using SqlSugar;
using System.Data;
using System.Data.Common;
using System.Linq.Expressions;

namespace WLYT.Core
{
    public interface IRepository<T> : ISimpleClient<T> where T : class, new()
    {

        Task<bool> DeleteAsync(string ids);
        Task<bool> DeleteAsync(int id);

        Task<List<T>> GetListAsync(bool isCache = false);

        Task<Tuple<IList<T>, int>> GetPageListAsync(Expressionable<T> whereExpression, int pageSize, int pageIndex, Expression<Func<T, object>>? orderByExpression = null, OrderByType orderByType = OrderByType.Desc);

        Task<Tuple<IList<T>, int>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, int pageSize, int pageIndex, Expression<Func<T, object>>? orderByExpression = null, OrderByType orderByType = OrderByType.Desc);

        Task<Tuple<IList<T>, int>> GetPageListAsync(List<IConditionalModel> conditionalList, int pageSize, int pageIndex, Expression<Func<T, object>>? orderByExpression = null, OrderByType orderByType = OrderByType.Desc);

        Task<DataSet> GetProcedureDataSetAsync(string sql, List<SugarParameter>? parameters = null);

        Task<DataTable> GetProcedureDataTableAsync(string sql, List<SugarParameter>? parameters = null);

        Task<int> ExecuteCommandAsync(string sql, List<SugarParameter>? parameters = null);

        Task<bool> SplitTableInsertAsync(T input);

        Task<bool> SplitTableInsertAsync(List<T> input);

        Task<bool> SplitTableUpdateAsync(T input);

        Task<bool> SplitTableUpdateAsync(List<T> input);

        Task<bool> SplitTableDeleteableAsync(T input);

        Task<bool> SplitTableDeleteableAsync(List<T> input);

        Task<T> SplitTableGetFirstAsync(Expression<Func<T, bool>> whereExpression);

        Task<bool> SplitTableIsAnyAsync(Expression<Func<T, bool>> whereExpression);

        Task<List<T>> SplitTableGetListAsync();

        Task<List<T>> SplitTableGetListAsync(Expression<Func<T, bool>> whereExpression);

        Task<List<T>> SplitTableGetListAsync(Expression<Func<T, bool>> whereExpression, string[] tableNames);
    }
}
